# groups.cmake

# group STARTUP
add_library(Group_STARTUP OBJECT
  "${SOLUTION_ROOT}/firmware/CMSIS/device/startup/startup_n32g45x.s"
)
target_include_directories(Group_STARTUP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
)
target_compile_definitions(Group_STARTUP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_STARTUP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
target_link_libraries(Group_STARTUP PUBLIC
  ${CONTEXT}_ABSTRACTIONS
)
set(COMPILE_DEFINITIONS
  N32G45X N32G457 USE_STDPERIPH_DRIVER
)
cbuild_set_defines(AS_ARM COMPILE_DEFINITIONS)
set_source_files_properties("${SOLUTION_ROOT}/firmware/CMSIS/device/startup/startup_n32g45x.s" PROPERTIES
  COMPILE_FLAGS "${COMPILE_DEFINITIONS}"
)

# group CMSIS
add_library(Group_CMSIS OBJECT
  "${SOLUTION_ROOT}/firmware/CMSIS/device/system_n32g45x.c"
)
target_include_directories(Group_CMSIS PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
  ${SOLUTION_ROOT}/firmware/CMSIS/device
)
target_compile_definitions(Group_CMSIS PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_CMSIS PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
target_link_libraries(Group_CMSIS PUBLIC
  ${CONTEXT}_ABSTRACTIONS
)

# group FWLB
add_library(Group_FWLB OBJECT
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/misc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_adc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_bkp.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_can.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_comp.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_crc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_dac.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_dbg.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_dma.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_dvp.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_eth.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_exti.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_flash.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_gpio.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_i2c.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_iwdg.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_opamp.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_pwr.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_qspi.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_rcc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_rtc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_sdio.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_spi.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_tim.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_tsc.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_usart.c"
  "${SOLUTION_ROOT}/firmware/n32g45x_std_periph_driver/src/n32g45x_wwdg.c"
)
target_include_directories(Group_FWLB PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
)
target_compile_definitions(Group_FWLB PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_FWLB PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
target_link_libraries(Group_FWLB PUBLIC
  ${CONTEXT}_ABSTRACTIONS
)

# group USER
add_library(Group_USER OBJECT
  "${SOLUTION_ROOT}/user/src/main.c"
  "${SOLUTION_ROOT}/user/src/n32g45x_it.c"
)
target_include_directories(Group_USER PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
  ${SOLUTION_ROOT}/user/inc
)
target_compile_definitions(Group_USER PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_USER PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
target_link_libraries(Group_USER PUBLIC
  ${CONTEXT}_ABSTRACTIONS
)

# group BSP
add_library(Group_BSP OBJECT
  "${SOLUTION_ROOT}/bsp/bsp_systick.c"
  "${SOLUTION_ROOT}/bsp/bsp_task.c"
  "${SOLUTION_ROOT}/bsp/bsp_key.c"
  "${SOLUTION_ROOT}/bsp/bsp_led.c"
  "${SOLUTION_ROOT}/bsp/bsp_tim.c"
)
target_include_directories(Group_BSP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
  ${SOLUTION_ROOT}/bsp
)
target_compile_definitions(Group_BSP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_BSP PUBLIC
  $<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
target_link_libraries(Group_BSP PUBLIC
  ${CONTEXT}_ABSTRACTIONS
)
